//
//  NavegationItem.swift
//  WBTest
//
//  Created by pengZY on 2017/9/26.
//  Copyright © 2017年 zhang. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    convenience public init(title:String,target:Any?,selector:Selector,isBack:Bool) {
        let btn = UIButton.init(frame: CGRect(x: 0, y: 0, width: 30, height: 30))
      //  btn.backgroundColor = UIColor.red
        btn.titleLabel?.font = UIFont.systemFont(ofSize: 14.0)
        btn.setTitleColor(UIColor.lightGray, for: .normal)
        btn.setTitleColor(UIColor.orange, for: .highlighted)
        btn.setTitle(title, for: .normal)
        if isBack {
            btn.setImage(UIImage.init(named: "navigationbar_back"), for: .normal)
            btn.setImage(UIImage.init(named: "navigationbar_back_highlighted"), for: .highlighted)
        }
        btn.sizeToFit()
        btn.addTarget(target, action: selector, for: .touchUpInside)
        self.init(customView: btn)
    }
}
